<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>全选</title>
</head>
<body>
全选<input class="btn" type="checkbox">
<ul>
    <li><input type="checkbox">杜比环绕，家庭影院必备，超真实享受</li>
    <li><input type="checkbox">NVDIA 99999GT 2G 1024bit极品显卡，不容错过</li>
    <li><input type="checkbox">精品热卖，高清晰，45寸LED电视</li>
    <li><input type="checkbox">Sony索尼家用最新款笔记本</li>
    <li><input type="checkbox">华为，荣耀3C，超低价，性价比奇高</li>
</ul>
<script>
    let btn = document.getElementsByClassName('btn')[0];
    let inputArr = document.getElementsByTagName('ul')[0].getElementsByTagName('input');
    btn.onclick = function() {
        let bool = btn.checked;
        for (let i = 0; i < inputArr.length; i++) {
            inputArr[i].checked = bool;
        }
    }
</script>
</body>
</html>